package com.caozhi.mspeoject.nb_message.service.admin.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.caozhi.mspeoject.nb_message.bean.Article;
import com.caozhi.mspeoject.nb_message.mapper.ArticleMapper;
import com.caozhi.mspeoject.nb_message.remote.DistributedId;
import com.caozhi.mspeoject.nb_message.service.admin.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ArticleServiceImpl extends ServiceImpl<ArticleMapper , Article> implements ArticleService {
    @Autowired
    private ArticleMapper articleMapper;
    @Autowired
    private DistributedId distributedId;
    @Override
    public void addArticle(Article article) {
        article.setId(distributedId.getDistributeID());
        articleMapper.insert(article);
    }

    @Override
    public Article findArticleById(Long Id) {
        LambdaQueryWrapper<Article> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(Article::getId , Id);
        return articleMapper.selectOne(lambdaQueryWrapper);
    }
}
